
% This is the function for plotting figure 3 and 4.
% Complete Date: June 15th 2021

% Fig. 3. Expected overflow from slot I.
% Fig. 4. Expected number of slot overflows per patient.

function figure3_4(j_all, N)

    figure(3);
    global P
    P = [.1, .5, .9];

    [~, ~, EYI_p, EYin_p, ~] = prop_policy(j_all, N);
    [~, ~, EYI_r, EYin_r, ~] = round_robin(j_all,N);


    EYI_p = EYI_p(1,1:34);
    EYin_p = EYin_p(1,1:34);
    EYI_r = EYI_r(1,1:34);
    EYin_r = EYin_r(1,1:34);
    n = 34;

    subplot(1,2,1)
    % Firstly, we draw figure 3.
    plot(1:n, EYI_p, 'k')
    hold on
    plot(1:n, EYI_r, 'k--')
    hold off
    axis ([0 35 0 2.5]);
    xlabel ('Number of Assigned Patients (n)')
    ylabel ('E(Yn_I)')
    legend ('Proposed Policy', 'Round Robin', 'Location', 'northwest')
    title ('Figure 3: Expected overflow (I)')


    subplot(1,2,2)
    % Then, we draw figure 4.
    plot (1:n, EYin_p, 'k')
    hold on
    plot (1:n, EYin_r, 'k--')
    hold off
    axis ([0 35 0 0.25]);
    xlabel ('Number of Assigned Patients (n)')
    ylabel ('E(\Sigma Y_i^n) / n')
    legend ('Proposed Policy', 'Round Robin', 'Location', 'northwest')
    title ('Fig 4: Expected overflows per patient.')

    end
